<?php
if($_REQUEST['_a'] == "del") {
	$sql = "delete from tooltip where id='".$_REQUEST['_d']."'";
	mysql_query($sql) or die(mysql_error());
}
?>

<script type="text/javascript">
jQuery(document).ready(function($) {
  $('a[rel*=facebox]').facebox();
}) 

function show() {
	document.adfrm.action="index.php?tc=ads_add";
	document.adfrm.submit();
}
</script>
<form name="adfrm" method="post" action="#">
<table border="0" width="100%" align="center">
<tr>
	<td align="left"><span style="color:#1B78B7; font-size:14px; font-weight:bold">Tooltip</span>&nbsp;
	</td>
    <td width="40%" align="right" class="font12">
    <a href="index.php?tc=add_tooltip" class="font12">Add New</a></td>
</tr>
<tr>
	<td background="images/topline.gif" colspan="2" height="11"></td>
</tr>    
</table>
</form> 
	<?php
if($_REQUEST['_s'] == 2)
{ ?>
	<table align="center" border="0">
	<tr>
    	<td align="center"><div class="sucmsg"><img src="images/information.png" align="absmiddle" />&nbsp;Deleted Successfully</div></td>
    </tr>    
    </table>
<?php } ?>
<table width="100%" align="center" border="0" class="list">
<thead>
<tr>
	<td align="center" width="38">#</td>
	<td align="center" width="268">Terms</td>
    <td align="center" width="299">Definition</td>
    <td align="center">URL</td>
    </tr>
</thead>
<?php
include('includes/function.php');
$self="index.php?tc=tooltip";
$rowsPerPage = 20;
$pageNum = 1;
if(isset($_GET['page']))
{
	$pageNum = $_GET['page'];
}
if($_GET['page']=="")
{
	$pageNum = 1;
}

/*<!--counting the offset-->*/
$offset = ($pageNum - 1) * $rowsPerPage;
$st = $_REQUEST['_st'];

$res = mysql_query("select id from tooltip");

$query = mysql_query("select * from tooltip where 1 order by id desc limit $offset , $rowsPerPage") or die(mysql_error());

$i = 1;
while($q = mysql_fetch_array($query))
{ 
?>
    <tr class="font12">
        <td align="center"><?php echo $i+$offset;?></td>
        <td align="left"><?php echo $q["terms"];?></td>
        <td align="center"><?php echo $q["definition"];?></td>
         <td align="center"><?php echo $q["url"];?></td>
    </tr>     
<?php 
	$i++;
}
?>
<?php 
if(mysql_num_rows($res) <= $rowsPerPage){	}
else { ?>
<tr>
    <td colspan="6" align="center"  bgcolor="#E3ECF3">
        <?php echo $paginglink=getPagingLink($res, $rowsPerPage,$pageNum,$self); ?>	
    </td>
</tr>
<?php } ?>
</table>    